from create import session
from create_otm import UserOtm, Role

# 正向查询
print('正向查询')
res = session.query(UserOtm).all() # 查询所有的用户和角色
for i in res:
    print(i.name, i.group.role_name)

# 反向查找
print('反向查找')
res = session.query(Role).filter(Role.role_name == 'dba').first() # 查找dba组下的所有用户
print(res.uuu)
for i in res.uuu:
    print(i.name, res.role_name)